package com.sfh.cpc.mass.model;

import com.sfh.cpc.com.entity.EMass;
import com.sfh.cpc.com.entity.RspBase;
import com.sfh.cpc.com.req.ReqFile;
import com.sfh.cpc.com.req.ReqMassAdd;
import com.sfh.lib.exception.HandleException;
import com.sfh.lib.mvvm.service.BaseViewModel;
import com.sfh.lib.rx.IResult;

/**
 * 功能描述: TODO
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/27
 */
public class MassAddModel extends BaseViewModel {
    public void updateFile(String loanPath) {

        this.execute(new ReqFile(loanPath), new IResult<RspBase<String>>() {
            @Override
            public void onSuccess(RspBase<String> data) throws Exception {
                setValue("onSaveFile", data);
            }
            @Override
            public void onFail(HandleException e) {
                showToast(e.getMsg());
            }
        });
    }

    public void saveMass(ReqMassAdd massAdd) {
        if (massAdd.chechParams(this)){
            return;
        }
        this.execute(false, massAdd, new IResult<RspBase<Boolean>>() {
            @Override
            public void onSuccess(RspBase<Boolean> data) throws Exception {
                if (data.success()){
                    setValue("onSaveMassSuccess");
                }else{
                    showToast(data.getMsg());
                }

            }

            @Override
            public void onFail(HandleException e) {
                showToast(e.getMsg());
            }
        });
    }
}
